﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace www.pages.project
{
    public partial class list : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                BindData();
            }
        }

        private string InitSql() {
            if (txtProjectName.Value != "") {
                return $" project_name like '%{txtProjectName.Value.Trim()}%'";
            }
            return "";
        }

        private void BindData()
        {
            int recordcount = 0;
            this.list_data.DataSource = Core.Core.ProjectUtil.GetList(InitSql(), "create_date desc", Pager.CurrentPageIndex, Pager.PageSize, ref recordcount);
            this.list_data.DataBind();

            Pager.RecordCount = recordcount;
        }

        protected void Pager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            Pager.CurrentPageIndex = e.NewPageIndex;
            BindData();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }
    }
}